<script>
	export default {
		data() {
			return {
				firstBackTime: 0
			}
		},
		onLaunch: function() {
			console.warn('当前组件仅支持 uni_modules 目录结构 ，请升级 HBuilderX 到 3.1.0 版本以上！')
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		onLastPageBackPress: function() {
			console.log('App LastPageBackPress')
			if (this.firstBackTime == 0) {
				uni.showToast({
					title: '再按一次退出应用',
					position: 'bottom',
				})
				this.firstBackTime = Date.now()
				setTimeout(() => {
					this.firstBackTime = 0
				}, 2000)
			} else if (Date.now() - this.firstBackTime < 2000) {
				this.firstBackTime = Date.now()
				uni.exit()
			}
		},
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uni-scss/index.scss';
	/* #ifndef APP-NVUE */
	@import '@/static/customicons.css';

	// 设置整个项目的背景色
	page {
		background-color: #f5f5f5;
	}

	/* #endif */
	.example-info {
		font-size: 14px;
		color: #333;
		padding: 10px;
	}
</style>